package cn.szq.springframework.beans;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/***
 * All rights Reserved, Designed By www.jx-lab.com
 * @Title: PropertyValues
 * @Description:
 * @author lixy
 * @date 2021/8/12 11:54
 * @version V1.0
 * @Copyright: www.jx-lab.com Inc. All rights reserved.
 * 注意：本内容仅限于众合景轩信息技术有限公司内部传阅，禁止外泄以及用于其他的商业目
 */
public class PropertyValues {

    private final List<PropertyValue> propertyValueList = new ArrayList<>();

    public void addPropertyValue(PropertyValue pv){
        propertyValueList.add(pv);
    }

    public PropertyValue[] getPropertyValues() {
        return this.propertyValueList.toArray(new PropertyValue[0]);
    }

    public PropertyValue getPropertyValue(String propertyName){
        List<PropertyValue> collect = propertyValueList.stream().filter(t -> t.getName().equals(propertyName)).collect(Collectors.toList());
        if (!collect.isEmpty()){
            return collect.get(0);
        }
        return null;
    }
}
